//
//  MYGChooseViewCell.swift
//  MYGrow
//
//  Created by 林矗 on 2024/3/17.
//

import UIKit

class MYGChooseViewCell: UICollectionViewCell {
    // MARK: - Property
    var title: String? {
        didSet {
            guard let title = title else { return }
            titleLabel.text = title
        }
    }
    
    var myg_isSelected: Bool = false {
        didSet {
            titleLabel.textColor = myg_isSelected ? .white : .rgba(51, 52, 67)
            contentView.backgroundColor = myg_isSelected ? .rgba(162, 146, 254) : .rgba(243, 243, 246)
        }
    }
    
    // MARK: - init
    override init(frame: CGRect) {
        super.init(frame: frame)
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - UI
    private func configUI() {
        contentView.backgroundColor = .rgba(243, 243, 246)
        contentView.layerCornerRadius = 2.5
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    
    // MARK: - lazy load
    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = .regular(12)
        label.textColor = .rgba(51, 52, 67)
        label.textAlignment = .center
        return label
    }()
}
